<%@ page language="java" contentType="text/html;charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<fmt:setBundle basename="top.wsuo.message.blog"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><fmt:message key="message.message.title"/></title>
    <link rel="stylesheet" href="../static/css/uikit.min.css">
    <link rel="stylesheet" href="../static/css/uikit.gradient.min.css">
    <link rel="stylesheet" href="../static/css/awesome.css">
    <script src="../static/js/jquery.min.js"></script>
    <script src="../static/js/uikit.min.js"></script>
</head>
<body class="uk-height-1-1">
<%--使用静态包含: 顶部导航栏--%>
<%@include file="/component/header.jsp" %>
<div class="uk-container uk-container-center">
    <div class="uk-grid">
        <!-- content -->
        <!-- 配置数据源 -->
        <sql:setDataSource dataSource="jdbc/mysql" var="mysql"
                           scope="request"/>
        <!-- 取得查询结果集 -->
        <sql:query sql="select * from HW_Message "
                   dataSource="${ mysql }"
                   var="listMessage"
                   scope="request">
        </sql:query>
        <div class="uk-width-medium-3-4">
            <!-- 输出 -->
            <c:forEach var="message" items="${ listMessage.rows }">
                <c:choose>
                    <c:when test="${ message.username == user.getUsername() }">
                        <article class="uk-comment uk-comment-primary">
                            <header
                                    class="uk-comment-header">
                                <img class="uk-comment-avatar"
                                     src="../static/img/usericon.svg"
                                     width="50" height="50" alt="">
                                <h4 class="uk-comment-title">
                                        ${ message.username }
                                </h4>
                                <ul class="uk-comment-meta uk-subnav uk-subnav-line">
                                    <li>
                                        <span>
                                                ${ message.time }
                                        </span>
                                    </li>
                                    <li>
                                        <a href="remove.do?number=${ message.number }" style="color: red">
                                            <fmt:message key="message.message.remove"/>
                                        </a>
                                    </li>
                                </ul>
                            </header>
                            <div class="uk-comment-body">
                                <p>${ message.content }</p>
                            </div>
                        </article>
                        <hr class="uk-article-divider">
                    </c:when>
                    <c:otherwise>
                        <article class="uk-comment">
                            <header class="uk-comment-header">
                                <img class="uk-comment-avatar"
                                     src="../static/img/usericon.svg"
                                     width="50" height="50" alt="">
                                <h4 class="uk-comment-title">
                                        ${ message.username }
                                </h4>
                                <div class="uk-comment-meta">
                                        ${ message.time }
                                </div>
                            </header>
                            <div class="uk-comment-body">
                                <p>${ message.content }</p>
                            </div>
                        </article>
                        <hr class="uk-article-divider">
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </div>
        <!-- // content -->
    </div>
</div>
<%--底部栏目--%>
<%@include file="/component/footer.jsp" %>
</body>
</html>